package oficina;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class RecibirRodamientos extends javax.swing.JFrame {
	private JLabel lblRodamiento;
	private JComboBox jComboBoxRodamientos;
	private JButton jButtonEliminar;
	private JButton jButtonAgregar;
	private JTextField txtCantidad;
	private JLabel lblCantidad;
	private JScrollPane jScrollPane1;
	private JButton jButtonCancelar;
	private JButton jButtonAceptar;
	private JTable jTable1;
	private TableModel jTable1Model;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				RecibirRodamientos inst = new RecibirRodamientos();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public RecibirRodamientos() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				lblRodamiento = new JLabel();
				getContentPane().add(lblRodamiento);
				lblRodamiento.setText("RODAMIENTO");
				lblRodamiento.setBounds(18, 12, 113, 16);
			}
			{
				ComboBoxModel jComboBoxRodamientosModel = 
						new DefaultComboBoxModel(
								new String[] { "Item One", "Item Two" });
				jComboBoxRodamientos = new JComboBox();
				getContentPane().add(jComboBoxRodamientos);
				jComboBoxRodamientos.setModel(jComboBoxRodamientosModel);
				jComboBoxRodamientos.setBounds(125, 9, 247, 23);
			}
			{
				jTable1Model = 	new DefaultTableModel(new String[][]{ },new String[]{"Codigo","Nombre","Origen","Marca","Cantidad"});
				
				jScrollPane1 = new JScrollPane();
				getContentPane().add(jScrollPane1);
				jScrollPane1.setBounds(12, 96, 413, 147);			
				
				jTable1 = new JTable();
				jScrollPane1.setViewportView(jTable1);
				jTable1.setModel(jTable1Model);
				jTable1.setBounds(12, 161, 608, 190);
				DefaultTableCellRenderer  modelocentrar = new DefaultTableCellRenderer ();
	            modelocentrar.setHorizontalAlignment(SwingConstants.CENTER);
	            jTable1.getColumnModel().getColumn(0).setCellRenderer(modelocentrar);
	            jTable1.getColumnModel().getColumn(1).setCellRenderer(modelocentrar);
	            jTable1.getColumnModel().getColumn(2).setCellRenderer(modelocentrar);
	            jTable1.getColumnModel().getColumn(3).setCellRenderer(modelocentrar);
	            jTable1.getColumnModel().getColumn(4).setCellRenderer(modelocentrar);
			}
			{
				lblCantidad = new JLabel();
				getContentPane().add(lblCantidad);
				lblCantidad.setText("CANTIDAD");
				lblCantidad.setBounds(18, 60, 81, 16);
			}
			{
				txtCantidad = new JTextField();
				getContentPane().add(txtCantidad);
				txtCantidad.setBounds(125, 57, 90, 23);
			}
			{
				jButtonAgregar = new JButton();
				getContentPane().add(jButtonAgregar);
				jButtonAgregar.setText("+");
				jButtonAgregar.setBounds(239, 57, 43, 23);
				jButtonAgregar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						try{
							DefaultTableModel temp = (DefaultTableModel) jTable1.getModel();
							int cantidad=Integer.valueOf(txtCantidad.getText());
							Object nuevo[]= {"HOLA","SOY","JUAN","BOLIVIANO",cantidad};
							temp.addRow(nuevo);
						}catch(Exception e){
							
						}
						
					}
				});
			}
			{
				jButtonEliminar = new JButton();
				getContentPane().add(jButtonEliminar);
				jButtonEliminar.setText("-");
				jButtonEliminar.setBounds(301, 57, 43, 23);
				jButtonEliminar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						DefaultTableModel temp = (DefaultTableModel) jTable1.getModel();
						Object nuevo[]= {"HOLA","SOY","JUAN","BOLIVIANO"};
						temp.removeRow(jTable1.getSelectedRow()); 
					}
				});
			}
			{
				jButtonAceptar = new JButton();
				getContentPane().add(jButtonAceptar);
				jButtonAceptar.setText("ACEPTAR");
				jButtonAceptar.setBounds(81, 267, 98, 35);
				jButtonAceptar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						System.out.println("jButtonAceptar.actionPerformed, event="+evt);
						//TODO add your code for jButtonAceptar.actionPerformed
					}
				});
			}
			{
				jButtonCancelar = new JButton();
				getContentPane().add(jButtonCancelar);
				jButtonCancelar.setText("CANCELAR");
				jButtonCancelar.setBounds(239, 267, 98, 35);
				jButtonCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
					}
				});
			}
			pack();
			this.setSize(453, 355);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
